<?php
/* 后台用户表
* @Author: Jerry-chen
* @Date:   2014-07-06 18:39:11
* @Last Modified time: 2014-07-06 23:36:45
* @Last Modified by: Jerry-chen<uranusbill@163.com>
* @ Copyright (c) 2014 http://www.cooldreamer.com All rightsreserved.
*/
class AdminModel extends Model
{
	//指定要处理的表】
	public $table = 'admin';
	/**验证登陆 
	 * [validate_login description]
	 * @return [type] [description]
	 */
	public function validate_login()
	{
		//验证-验证码
		 $code = Q('post.code','','strtoupper');
		if($code!=session('code'))
		{
			$this->error('验证码不正确');
			return false;
		}
		//获得用户提交验证用户名和密码 
		$username = Q('post.username');
		$password = Q('post.password','','md5');
		//获得数据库中的信息
		$userData = $this->where(array('username'=>$username))->find();
		if(!$userData||$username!=$userData['username']||$password!=$userData['password'])
		{

			$this->error('用户名或密码错误');

			return false;
		}
		//如果前面的都通过，证明用户名和密码都是对的

		return $userData;
	}
}
?>
